<?php
$head_httpdvb = 'http://httpdvb.slave.nx96200.cn:13164/playurl';
$head_httpstream = 'http://stream.slave.nx96200.cn:13164/playurl';

$id = isset($_GET['id'])?$_GET['id']:'119';
$accesstoken = 'R60D35BAAU30912182K776AE004ICC9166B4PBM323D35AV1020DZ9C465W168B41AC189827EC';
//备用sccesstoken：R5ECA3A64U3191B163K776AAA45I98525ADEPBM3238581V0Z9C465W1611EBE7BE3AEBED、R5E527FBEU319AC163K7768D0EEI59A8C401PBM321BC1AV0Z9C465W15F60B7EBB17EFE8、R5EDED88FU30990082K776ABB09I32F98767PBM323A1A7V0Z9C465W1616B8D311E6D9E9

$url = 'http://slave.nx96200.cn:13160/media/channel/get_info?chnlid=4200900'.$id.'&accesstoken='.$accesstoken;
$result = file_get_contents($url);
$json = json_decode($result);
$_playtoken = array('31649KBRUYVTKBX10','31648YBGNZQKEGQ10');
$playtoken = isset($json->play_token)?$json->play_token:$_playtoken[mt_rand(0,1)];

$start='';
$end='';
$isplayback=false;
if(isset($_GET['start'])&isset($_GET['end'])){
    $start=$_GET['start'];
    $end=$_GET['end'];
    $pf_id=$json->pf_info[0]->id;
    $isplayback=true;
}

if($isplayback){
    $playurl=$head_httpstream.'?playtype=lookback&protocol=hls&starttime='.$start.'&endtime='.$end.'&verifycode=2003492868&programid='.$pf_id.'&accesstoken='.$accesstoken.'&playtoken='.$playtoken;
}else{
    $playurl=$head_httpdvb.'?playtype=live&protocol=hls&verifycode=2003492868&programid=4200900'.$id.'&accesstoken='.$accesstoken.'&playtoken='.$playtoken;
}

//echo $url;
header("location: ".$playurl);
?>